Skip to content

通信sms微服务

通信 sms 微服务模块

通信 sms 微服务模块是放置在 gm_server_notify 工程中

/sms/send/add 添加发送短信任务

接口:
    /sms/send/add
class:
    sms/views.py/SmsSendAddView
方法:
    POST
请求:
    station_id        M    String    站点id
    restaurant_id     O    Int       店铺id
    receive_name      O    String    收信方姓名
    receive_phone     M    String    收信方手机号码
    sms_content       O    Dict
        {
            # 内容与 business_type 保持一致
            # 创建订单时的短信内容
            order_id         M    String    订单id
            sms_signature    M    String    短信签名
            # 用户注册时的短信内容
            verify_code      M    String    验证码
            sms_signature    M    String    短信签名
        }
    business_type     M    Int       业务类型
响应:
    code              M    Int       状态码
    msg               M    String    状态消息
    data              M    Dict      响应消息
        {
            task_id   M    Int       任务id
        }
示例:
    请求:
        {
            station_id: T7442,
            receive_phone: 13112341234,
            sms_content:
                {
                    "verify_code": "112095",
                    "sms_signature": "[去采购报价单]"
                },
            business_type: 2
        }
    响应:
        {
            code: 0,
            msg: 'ok',
            data:
                {
                    task_id: 22
                }
        }
说明:
    返回的 task_id 是「tbl_sms_send_record」的主键id

/sms/send/start 发送短信

接口:
    /sms/send/start
class:
    sms/views.py/SmsSendStartView
方法:
    POST
请求:
    task_id    M    Int       短信任务id
响应:
    code       M    Int       状态码
    msg        M    String    状态消息
    data       M              响应内容
示例:
    请求:
        {
            task_id:  222
        }
    响应:
        {
            code: 0,
            msg: 'ok',
            data: null
        }
说明:
    一般是在创建短信发送记录后,将记录的id返回个调用方,然后调用方在调用短信的发送接口在进行发送

/sms/combo/get 获取套餐包

接口:
    /sms/combo/get
class:
    sms/views.py/ComboGetView
方法:
    GET
请求:
    无
响应:
    code      M    Int           状态码
    msg       M    String        状态信息
    data      M    List<Dict>    响应内容
        [
            {
                id            M    Int       套餐id
                name          M    String    套餐名字
                price         M    String    套餐价格
                sms_nums      M    Int       套餐条数
                unit          M    String    单位
                unit_price    M    Int       单价(分)
            },
            ...
        ]
示例:
    请求:
        无
    响应:
        {
            code: 0,
            msg: 'ok',
            data: 
                [
                    {
                        id: 1
                        name: "套餐包: 2000条"
                        price: "200.00"
                        sms_nums: 2000
                        unit: "条"
                        unit_price: 10
                    },
                ]
        }
说明:

/sms/balance/get 获取短信余额

接口:
    /sms/balance/get
class:
    sms/views.py/BalanceGetView
方法:
    GET
请求:
    station_id     M    String    站点id
响应:
    code           M    Int       状态码
    msg            M    String    状态信息
    data           M    Dict      响应内容
        {
            sms_balance    M    Int       短信余额
        }
示例:
    请求:
        {
            station_id: 'T7442'
        }
    响应:
        {
            code: 0,
            msg: 'ok',
            data: 
                {
                    sms_balance: 178
                }
        }   
说明:
    根据「站点id」进入「tbl_sms_statistics」查询「balance_nums」并返回

/sms/data_center/get 获取短信近期每天发送详情

接口:
    /sms/data_center/get
class:
    sms/views.py/DataCenterGetView
方法:
    GET
请求:
    station_id     M    String        站点id
    start_date     M    Date          开始日期
    end_date       M    Date          结束日期
响应:
    code           M    Int           状态码
    msg            M    String        状态信息
    data           M    List<Dict>    响应内容   
        [
            {
                send_date               M   DateTime    发送时间
                total_send_nums         M   Int         总的发送数量
                success_send_nums       M   Int         发送成功数
                send_failed_nums        M   Int         发送失败数
            },
            ...
        ]
示例:
    请求:
        {
            station_id: 'T7442'
            start_date: '2019-04-28',
            end_date: '2019-05-28'
        }
    响应:
        {
            code: 0,
            msg: 'ok',
            data:
                [
                    {
                        "send_date": "2018-05-08",
                        "total_send_nums": 100,
                        "success_send_nums": 90,
                        "send_failed_nums": 10
                    },
                    {
                        "send_date": "2018-05-09",
                        "total_send_nums": 100,
                        "success_send_nums": 90,
                        "send_failed_nums": 10
                    },
                    ...
                ]
        }
说明:
    根据「站点id, 起止时间」进入「tbl_sms_send_record」查询发送记录,并返回统计数据

/sms/recharge_record/get 获取充值记录

接口:
    /sms/recharge_record/get
class:
    sms/views.py/RechargeRecordGetView
方法:
    GET
请求:
    station_id    M    String        站点id
    start_date    O    String        开始日期
    end_date      O    String        结束日期
    q             O    String        查询字段
    page_obj      O    String        分页对象(起始页)
    reverse       O    Bool          分页 是否反向查询
    limit         O    Int           分页 返回条数
响应:
    code          M    Int           状态码
    msg           M    String        状态信息
    data          M    List<Dict>    响应信息
        [
            {
                recharge_date     M    DateTime    充值时间
                station_id        M    String      站点id
                combo_id          M    Int         套餐id
                combo_name        M    String      套餐名称
                recharge_nums     M    Int         充值条数(条)
                recharge_money    M    String      充值金额(元)
                deal_code         M    String      到账凭证
                remark            M    String      备注
                operator_name     M    String      操作人
            },
            ...
        ]
示例:
    请求:
        {
            start_date: 2018-08-31
            end_date: 2018-09-30
            limit: 10
            offset: 0
        }
    响应:
        {
            code: 0,
            msg: 'ok',
            data:
                [
                    {
                        combo_id: 4
                        combo_name: "自定义套餐包"
                        recharge_date: "2018-09-26 11:25:35"
                        recharge_money: "0.30"
                        recharge_nums: 10
                        remark: "20180916"
                        station_id: "T7442"
                    },
                    ...
                ]
        }
说明:

/sms/recharge_record/create 创建充值记录

接口:
    /sms/recharge_record/create
class:
    sms/views.py/RechargeRecordCreateView
方法:
    POST
请求:
    combo_id          M    Int         套餐id
    station_id        M    String      站点id
    recharge_nums     M    Int         充值条数(条)
    recharge_money    M    String      充值金额
    operator_name     M    String      操作人
    deal_code         O    String      到账凭证
    remark            O    String      备注
    unit_price        O    Float       单价
响应:
    code              M    Int         状态码
    msg               M    String      状态消息
    data              M                响应内容
示例:
    请求:
        {
            combo_id: 4
            recharge_money: 0.01
            recharge_nums: 1
            deal_code: 测试
            remark: 测试
            station_id: T7442
            operator_name: superadmin
        }
    响应:
        {
            code: 0,
            msg: 'ok',
            data: null
        }
说明:

/sms/send_record/get 获取站点发送记录

接口:
    /sms/send_record/get
class:
    sms/views.py/SendRecordGetView
方法:
    GET
请求:
    station_id     M    String        站点id
    start_date     M    Date          开始日期
    end_date       M    Date          结束日期
    search_text    O    String        搜索关键字
    business_type  O    Int           业务类型 不传获取商城下单/代下订单的sms
    status         O    Int           发送状态 默认成功和失败都拉取
    page_obj       O    String        分页对象(起始页)
    reverse        O    Bool          分页条件 是否反向查询
    limit          O    Int           分页条件 返回条数
响应:
    code           M    Int           状态码
    msg            M    String        状态信息
    data           M    List<Dict>    响应内容   
        [
            {
                business_type    M    Int       业务类型,0:商城下单, 1:代下订单, 2:注册
                receive_name     M    string    商户名
                receive_phone    M    Int       发送电话
                remark           M    String    如果发送失败, 此字段表示失败原因
                restaurant_id    M    Int       商户id
                send_time        M    DateTime  发送时间
                status           M    Int       发送状态码, 0:开始发送, 1:发送成功, 2:发送失败
            },
            ...
        ]
示例:
    请求:
        {
            station_id: 'T7442'
            start_date: '2019-04-28',
            end_date: '2019-05-28'
        }
    响应:
        {
            code: 0,
            msg: 'ok',
            data:
                [
                    {
                        business_type: 2
                        receive_name: null
                        receive_phone: "18617140030"
                        remark: ""
                        restaurant_id: null
                        send_time: "2019-05-24 10:17:04"
                        status: 1
                    },
                    ...
                ]
        }
说明:

/sms/statistics_overview/get 统计概览

接口:
    /sms/statistics_overview/get
class:
    sms/views.py/StatisticsOverviewGetView
方法:
    GET
请求:
    无
响应:
    code                   M    Int       状态码
    msg                    M    String    状态消息
    data                   M    Dict      响应内容
        {
            gm_balance             M    Int       运营商套餐余额
            saas_balance           M    String    SaaS客户短信余额
            saas_recharge_money    M    String    SaaS客户充值金额
        }
示例:
    请求:
        无
    响应:
        {
            code: 0,
            msg: 'ok',
            data:
                {
                    gm_balance: 30366
                    saas_balance: "153690"
                    saas_recharge_money: "21981.31"
                }
        }
说明:

/sms/statistics_detail/get 所有站点短信统计

接口:
    /sms/statistics_detail/get
class:
    sms/views.py/StatisticsDetailGetView
方法:
    GET
请求:
    station_ids           O    List<String>    站点id列表
        [
            station_id    O    String          站点id
            ...
        ]
    q                     O    String          搜索关键字(支持站点id或站点名称)
    page_obj              O    String          分页 起始页
    reverse               O    Bool            分页 是否反向查询
    limit                 O    Int             分页 返回数据的条数
响应:
    code                  M    Int             状态码
    msg                   M    String          状态消息
    data                  M    List<Dict>      响应消息
        [
            {
                sms_balance             M    Int       剩余短信数量
                station_id              M    String    站点id
                total_recharge_money    M    String    充值金额
                total_recharge_nums     M    Int       总购买条数
            },
            ...
        ]
示例:
    请求:
        {
            q: T7442
        }
    响应:
        {
            code: 0,
            msg: 'ok',
            data:
                [
                    {
                        sms_balance: 179
                        station_id: "T7442"
                        total_recharge_money: "20.31"
                        total_recharge_nums: 211
                    }
                ]
        }
说明:

/sms/callback 腾讯云短信回调 11111111111

接口:
    /sms/callback
class:
    sms/views.py/SmsCallbackView
方法:
    POST
请求:

响应:
    code        M    Int        状态码
    msg         M    String     状态消息
    data        M               响应消息
示例:
    请求:

    响应:
        {
            code: 0,
            msg: 'ok',
            data: null
        }
说明: